package com.atwisdom.star.controller;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ActionData;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.core.bsl.business.Impl.WorkReportBslServiceImpl;
import com.atwisdom.star.core.bsl.customized.impl.CustomizeBusinessBslServiceImpl;
import com.atwisdom.star.core.bsl.planner.Impl.PlannerBslServiceImpl;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/custom")
public class CustomController {

    private WorkReportBslServiceImpl workReportBslService;
    private PlannerBslServiceImpl plannerMRPBslService;

   private CustomizeBusinessBslServiceImpl customizeBusinessBslService;

    @Autowired
    public void setWorkReportBslService(WorkReportBslServiceImpl workReportBslService) {
        this.workReportBslService = workReportBslService;
    }

    @Autowired
    public void setPlannerMRPBslService(PlannerBslServiceImpl plannerMRPBslService) {
        this.plannerMRPBslService = plannerMRPBslService;
    }

    @Autowired
    public void setCustomizeBusinessBslService(CustomizeBusinessBslServiceImpl customizeBusinessBslService) {
        this.customizeBusinessBslService = customizeBusinessBslService;
    }

    /**
     * 获取系统所有模型摘要信息
     *
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @StarAnnotation
    @PostMapping(value = "/saleMRP")
    public ResultInfo<?> execSaleMRP(@RequestBody JSONObject dataObj) throws BusinessException {
        return plannerMRPBslService.execSalePlanMRP(dataObj);
    }

    /**
     * 获取系统所有模型摘要信息
     *
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @StarAnnotation
    @PostMapping(value = "/monthMRP")
    public ResultInfo<?> execMonMrp(@RequestBody JSONObject dataObj) throws BusinessException {
        return plannerMRPBslService.execMonthPlanMRP(dataObj);
    }

    /**
     * 合并计划订单为生产计划
     *
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @StarAnnotation
    @PostMapping(value = "/execCombined")
    public ResultInfo<?> execPlanOrderCombined(@RequestBody JSONObject dataObj) throws BusinessException {
        return plannerMRPBslService.execPlanOrderCombined(dataObj);
    }

    /**
     * 工单齐套分析
     * @param dataObj 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/execCompleteAnalysis")
    public ResultInfo<?> execCompleteAnalysis(@RequestBody JSONObject dataObj) throws BusinessException {
        return plannerMRPBslService.execCompleteAnalysis(dataObj);
    }


    /**
     * 工单齐套分析
     * @param dataObj 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/execOutsourcingOrder")
    public ResultInfo<?> execOutsourcingOrderQuantity(@RequestBody JSONObject dataObj) throws BusinessException {
        return plannerMRPBslService.execOutsourcingOrderQuantity(dataObj);
    }


    /**
     * 工单齐套分析
     * @param params 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/stopStatus")
    public ResultInfo<?> dealWorkReportStopStatus(@RequestBody JSONObject params) throws BusinessException {
        return workReportBslService.dealWorkReportStopStatus(params);
    }


    /**
     * 工单齐套分析
     * @param repairParam 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/genRepair")
    public ResultInfo<?> dealAbnormalFinishRepair(@RequestBody JSONObject repairParam) throws BusinessException {
        return workReportBslService.dealAbnormalFinishRepair(repairParam);
    }


    /**
     * 实例数据拆分
     * @param splitData 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/splitData")
    public ResultInfo<?> splitInstanceData(@RequestBody JSONObject splitData) throws BusinessException {
        return customizeBusinessBslService.splitInstanceData(splitData);
    }

    /**
     * 实例数据拆分
     * @param params 传参
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @PostMapping(value = "/splitPickData")
    public ResultInfo<?> splitPickMaterialData(@RequestBody JSONObject params) throws BusinessException {
        return customizeBusinessBslService.splitPickMaterialData(params);
    }



}
